package com.dgut.uhrs.controller;

import com.dgut.uhrs.bean.Area;
import com.dgut.uhrs.service.AreaService;
import com.dgut.uhrs.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Controller
public class AreaController {
    @Autowired
    private AreaService areaService;
    @Autowired
    private UserService userService;

    @RequestMapping(value = "/user/findAllRiskArea")
    @ResponseBody
    public List<Area> findAllRiskArea(HttpServletRequest request){
        if (userService.checkToken(request.getHeader("token"))) {
            return areaService.findAllRiskArea();
        }

        else{
            return null;
        }
    }
}
